package com.newbingo.action;

import com.googlecode.jsonplugin.annotations.JSON;
import com.newbingo.entity.BettingCell;
import com.newbingo.entity.Game;
import com.opensymphony.xwork2.ActionSupport;
import com.newbingo.service.imple.IBettingCellService;
import com.newbingo.util.*;

public class BettingCellAction extends ActionSupport {
	private IBettingCellService bettingCellService;
	//分页查询条件
	private int start;
	private int limit;
	private String gameName;
	private Pager pager;
	//获取游戏投注格增删改的值
	private BettingCell bettingCell;
	//方法的正确执行定义
	private Boolean success=false;
	
	/**
	 * 创建投注格
	 * @return
	 */
	public String createCell(){
		bettingCellService.createCell(bettingCell);
		success=true;
		return SUCCESS;
	}
	
	/**
	 * 删除投注格
	 * @return
	 */
	public String deleteCell(){
		bettingCellService.deleteCell(bettingCell);
		success=true;
		return SUCCESS;
	}
	
	/**
	 * 修改投注格
	 * @return
	 */
	public String updateCell(){
		BettingCell bc=bettingCellService.findById(bettingCell.getId());
		if (bettingCell==null) {
			success=false;
		}else {
			bc.setRate(bettingCell.getRate());
			bettingCellService.updateCell(bc);
			success=true;
		}
		return SUCCESS;
	}
	
	/**
	 * 查询投注格
	 * @return
	 */
	public String findByPage(){
		this.setPager(bettingCellService.findCellByPage(start, limit, gameName));
		success=true;
		return SUCCESS;
	}
	
	public BettingCell getBettingCell() {
		return bettingCell;
	}

	public void setBettingCell(BettingCell bettingCell) {
		this.bettingCell = bettingCell;
	}

	@JSON(serialize=false)
	public IBettingCellService getBettingCellService() {
		return bettingCellService;
	}

	public void setBettingCellService(IBettingCellService bettingCellService) {
		this.bettingCellService = bettingCellService;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public Pager getPager() {
		return pager;
	}

	public void setPager(Pager pager) {
		this.pager = pager;
	}
	
	public String getGameName() {
		return gameName;
	}

	public void setGameName(String gameName) {
		this.gameName = gameName;
	}

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}


}
